home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 16563 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.4 KB

  1. Path: mail2news.demon.co.uk!devmaccn.demon.co.uk
  2. From: Alan Griffiths <aGriffiths@ma.ccngroup.com>
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: The STL and nested structures
  5. Date: Thu, 11 Apr 1996 10:14:08 GMT
  6. Organization: CCN Market Analysis
  7. Distribution: world
  8. Message-ID: <35564965wnr@ma.ccngroup.com>
  9. References: <marnoldDpn0HH.3z2@netcom.com> <4ju9q7$fa1$1@mhadg.production.compuserve.com> <316a26d7.2989288@news.cyberport.com>
  10. Reply-To: aGriffiths@ma.ccngroup.com
  11. X-NNTP-Posting-Host: devmaccn.demon.co.uk
  12. X-Broken-Date: Thursday, Apr 11, 1996 10.14.08 GMT
  13. X-Newsreader: Newswin Alpha 0.6
  14. X-Mail2News-Path: devmaccn.demon.co.uk
  15.  
  16. In article: <marnoldDpn0HH.3z2@netcom.com>  marnold@netcom.com (Matt Arnold) writes:
  17. > tangent@cyberport.com (Warren Young) writes:
  18. > >Alan Huff <74312.2300@CompuServe.COM> wrote:
  19. > >>I am having a problem using the STL with structures defined within 
  20. > >>a class definition.  Consider the following code fragment.
  21. > >>
  22. > >>>#include <vector.h>
  23. > >>>class Bar {
  24. > >>>   struct Foo {
  25. > >>>      int   value;
  26. > >>>   };
  27. > >>>
  28. > >>>   vector< Foo > fooContainer;
  29. > >>>}
  30. > >>
  31. > >>The compiler I am using (VC 4.1) refuses to compile.  An error is 
  32. > >>generated the says "'Foo' : undeclared identifier" at line 75 in 
  33. > >>vector.h.
  34. > >It _is_ undeclared, just as a variable local to a function foo() is
  35. > >undeclared in a function bar().  What you want to say is:
  36. > >vector<Bar::Foo> fooContainer;
  37. > This should not be necessary.  Nested class Foo should be visible for
  38. > use in template member Bar::fooContainer.  fooContainer is in Bar's
  39. > scope.  There should be no problem referring to it within Bar.  
  40. > I think Visual C++ is broken on the above code.  It compiles fine in 
  41. > Borland C++.
  42.  
  43. MSVC4 gets the name bindings wrong (and from the above enquiry so 
  44. does 4.1).  The work-around is to move the declaration of Foo to 
  45. global, non-namespace scope and use a typedef within Bar.  (I know
  46. that's horrid - but that's Microsoft!)
  47.  
  48. > Is it true that STL is currently incorrectly implemented?
  49.  
  50. Yes, In so far as there is no compiler that would support a correct 
  51. implementation.  There are various partial implementations for various 
  52. compilers.
  53.  
  54.  
  55. Alan Griffiths               | Also editor of: The ISDF Newsletter
  56. Senior Systems Consultant,   | (An Association of C and C++ Users publication)
  57. CCN Group Limited.           | (ISDF editor  : isdf@octopull.demon.co.uk)
  58. (agriffiths@ma.ccngroup.com) | (For ACCU see : http://bach.cis.temple.edu/accu)
  59.  
  60.